package com.example.springbootorderrabbitmqconsoumer.service;

import com.example.springbootorderrabbitmqconsoumer.config.RabbitConfig;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@RabbitListener(queues = RabbitConfig.IMMEDIATE_QUEUE)
public class MsgReceiver {

    @RabbitHandler
    public void reveive(String msg) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("当前时间：" + sdf.format(new Date()));
        System.out.println("收到延时消息了:" + msg);
    }
}
